﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace TicketManagement
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int username = int.Parse(this.username.Text);
            string password = this.password.Text;
            int identity = 1;

            string connStr = "server=121.43.119.97;user id=root;password=h666niub;persistsecurityinfo=True;database=ticket_management_system";
            MySqlConnection conn = new MySqlConnection(connStr);
            conn.Open();

            try
            {
                string insertStr = "INSERT INTO user(userName,password,identity_id) VALUES (" + username + "," + password + "," + identity + ")";
                MySqlCommand cmd = new MySqlCommand(insertStr, conn);
                //通过sql语句对表添加数值
                cmd.ExecuteScalar();

                MessageBox.Show("注册成功！");
                conn.Close();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString() + "注册失败");
            }

        }
    }
}